function ReportAssistant() {
}
	
ReportAssistant.prototype.setup = function() { 
this.CommandMenuAttributes = {
										spacerHeight: 25,
										menuClass: 'no-fade',
									 };
		
		this.CommandMenuModel = {
									visible: true,
									items: [{}, {
									  		items: [{
													label: 'Continue',
													command: 'day'
												},
												{
													label: 'Store',
													command: 'store'
												}]
											}, {}
											]
								};
	this.controller.setupWidget(Mojo.Menu.commandMenu, this.CommandMenuAttributes, this.CommandMenuModel);  
	/*this.buttonAttributes = {};
	this.buttonModel = { 
		buttonLabel : 'Continue', 
		buttonClass : 'palm-button affirmative buttonfloat',
		disabled : false
		};

	this.controller.setupWidget("dayStart", this.buttonAttributes, this.buttonModel);
	Mojo.Event.listen(this.controller.get('dayStart'), Mojo.Event.tap, this.handleButtonPress.bind(this));*/
	/*  this.controller.setupWidget("informationList",
         this.attributes = {
             itemTemplate: 'models/listitem',
             listTemplate: 'models/listcontainer',
             swipeToDelete: false,
             reorderable: false,
             emptyTemplate:'models/emptylist'
         },
         this.model = {
         });*/

}


ReportAssistant.prototype.activate = function(event){
	
	var weatherGood;
	if (randRange(1,100) <= chanceOfRain){
		$(weatherReport).innerHTML = "It rained, " + temperature + " degrees";
		weatherGood = false;
	}else{
		$(weatherReport).innerHTML = "A sunny day, " + temperature + " degrees";
		weatherGood = true;
	}
	
	$(cupsMade).innerHTML = numberOfCups;
	
	var lemonLevelNumber = (Math.round(temperature / 10) - numberOfLemons) - 5;
	var sugerLevelNumber = Math.abs(((numberOfLemons / 3) - numberOfSuger));

	lemonLevelCalculator(lemonLevelNumber);
	sugerLevelCalculator(sugerLevelNumber);
	//$(sugerLevel).innerHTML = "Hello";
	//$(weatherReport).innerHTML = "Hello2";
	soldLevelCalculator(lemonLevelNumber, weatherGood);
	coolerCalculator();
	moneyCalculator();	
}

function dayStart(){
	dayNumber++;
	//numberOfLemons = 1;
	//numberOfSuger = 1;
	//numberOfCups = 1;
	//numberOfAds = 1;
	priceOfAds = 0.15;
	//price = 0.01;
	//pricePerCup = 0.11;
	//expenses = 0.11;
	chanceOfRain = 0;
	temperature = 0;
	messageTrue = false;
	sugerMessage = "";
	sugerGood = false;
	cupsSoldNumber = 0;
	if (dayNumber <= numberOfDays){
		Mojo.Controller.stageController.swapScene('day');
	}else if (dayNumber > numberOfDays){
		Mojo.Controller.stageController.swapScene('end');
	}
}
/*
 * Cleanup anything we did in the activate function
 */
ReportAssistant.prototype.deactivate = function(event){
	
}
	
/*
 * Cleanup anything we did in setup function
 */
ReportAssistant.prototype.cleanup = function(event){
	
}

ReportAssistant.prototype.store = function(event){
	Mojo.Controller.stageController.swapScene('store');
}


ReportAssistant.prototype.handleCommand = function (event) {
	this.controller=Mojo.Controller.stageController.activeScene();
    if (event.type == Mojo.Event.commandEnable &&
	    (event.command == Mojo.Menu.helpCmd)) {
         event.stopPropagation(); // enable help. now we have to handle it
    }
	 if (event.type == Mojo.Event.commandEnable &&
	    (event.command == Mojo.Menu.prefsCmd)) {
         event.stopPropagation(); // enable help. now we have to handle it
    }

	console.log("RIGHT HERE");
	if (event.type == Mojo.Event.command) {
		var youOrdered = "";
		console.log("SettingsSceneAssistant::handleCommand(): Got command: " + event.command);
		switch (event.command) {
			
			// another built-in menu item, but we've enabled it (see below in this method)
			// so now we have to handle it:
			case Mojo.Menu.helpCmd:
				Mojo.Controller.stageController.pushScene('support');
				break;
				
			case Mojo.Menu.prefsCmd:
				Mojo.Controller.stageController.pushScene('settings');
				break;
			case "day":
				dayStart();
				break;
			case "store":
				this.store();
				break;
		}
	}	
}

function randRange (small, big){
	return Math.floor(Math.random() * (small - big) + big);
}

	
function lemonLevelCalculator(lemonLevelNumber){
	var lemonMessage;
	switch(lemonLevelNumber){
		case -4 :
			lemonMessage = "Way too many.";
			break;
		case -3 :
			lemonMessage = "Too many.";
			break;
		case -2 :
			lemonMessage = "A little much.";
			break;
		case -1 :
			lemonMessage = "One too many.";
			break;
		case 0 :
			lemonMessage = "Perfect.";
			break;
		case 1 :
			lemonMessage = "Missing one.";
			break;
		case 2 :
			lemonMessage = "Not quite enough."
			break;
		case 3 :
			lemonMessage = "Too little.";
			break;
		case 4 :
			lemonMessage = "Not nearly enough.";
			break;
	}
	$(lemonLevel).innerHTML = lemonMessage;
}

function sugerLevelCalculator(sugerLevelNumber){
	var good = "Perfect";
	var oneMore = "One too little";
	var twoMore = "Two too little";
	var oneLess = "One too many";
	var twoLess = "Two too many";
	//$(lemonLevel).innerHTML = "Hello"
	//var sugerGood = false;
	if (numberOfLemons <= 2){
		if (numberOfSuger == 1){
			sugerMessage = good;
		}else if(numberOfSuger == 2){
			sugerMessage = oneLess;
		}else if (numberOfSuger == 3){
			sugerMessage = twoLess;
		}
	}else if (numberOfLemons <= 4){
		if (numberOfSuger == 1){
			sugerMessage = oneMore;
		}else if(numberOfSuger == 2){
			sugerMessage = good;
		}else if (numberOfSuger == 3){
			sugerMessage = oneLess;
		}
	}else{
		if (numberOfSuger == 1){
			sugerMessage = twoMore;
		}else if(numberOfSuger == 2){
			sugerMessage = oneMore;
		}else if (numberOfSuger == 3){
			sugerMessage = good;
		}
	}
	//sugerMessage = "Hello";
	$(sugerLevel).innerHTML = sugerMessage;
	//$(lemonLevel).innerHTML = "Hey";
	//return sugerGood;
}

function soldLevelCalculator(levelLemonNumber, weatherGood){
	var weatherAffect = 1;
	var sugerAffect = 1;
	var customers = ((temperature / 10) * 2) + (numberOfAds * 3);
	if (!weatherGood){
		weatherAffect = 2;
	}
	if (!sugerGood){
		sugerAffect = 2;
	}
	cupsSoldNumber = Math.round((((customers - (price * 10)) - (Math.abs(levelLemonNumber) * 3)) / sugerAffect) / weatherAffect);
	if (cupsSoldNumber < 0){
		cupsSoldNumber = 0;
	}else if (cupsSoldNumber > numberOfCups){
		cupsSoldNumber = numberOfCups;
	}
	$(cupsSold).innerHTML = cupsSoldNumber;
	//return cupsSoldNumber;
}

function coolerCalculator(){
	// calculate how many cups were not sold
	var left = numberOfCups - cupsSoldNumber;
	//$(lemonLevel).innerHTML = pricePerCup;
	// now see if that number is less then or equal to the cooler capacity
	if (left <= coolerCapacity){
		// now subtract the expenses of the remaning cups
		expenses -= left * (pricePerCup / 100);
	}else{
		// since there were more then the cooler capacity just subtract the cooler capacity
		expenses -= coolerCapacity * (pricePerCup / 100); 
	}
	//$(sugerLevel).innerHTML = expenses;
}

function moneyCalculator(){
	var profitNumber = Math.floor(((cupsSoldNumber * price) - expenses) * 100) / 100;
	$(profit).innerHTML = profitNumber;
	money += profitNumber;
	money = Math.floor(money * 100) / 100;
	$(funds).innerHTML = money;
}